<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />

        <title>Inhalt editieren</title>

        <usergroup>
            10
        </usergroup>

        <usergroup_edit>
            100
        </usergroup_edit>

        <template>
            script.html
        </template>

        <url>
            /data/content/save-edit
        </url>

        <title_active>
            0
        </title_active>
    </head>

    <body><?php
        require_once(config::$basePath . "/system/api/simplehtmldom/simple_html_dom.php");

        $contentId=request::post("content_id");
        $content=stripslashes(request::post("content_text"));

        $data=db::getDataLine("content", "id='$contentId'");

        $filename=$data['content_filename'];
        $text=request::post("content");

        $contentOrginal=file::readTextFile($filename, false);
        //$contentOrginal = dom::setTag("body", $content, $contentOrginal);
        $contentOrginal=dom::replaceInnerHtml("body", $content, $contentOrginal);

        file::createTextFile($filename, $contentOrginal, false);


        /*$content = new content();
                                   //$content->title = $title;
                                   //$content->url = $url;
                                   $content->contentId = $data['id'];   
                                   $content->text = $content;
                                   /*$content->contentFilename = $filenameFrom;
                                   $content->template = $template;
                                   $content->header = $header;*/

        /* $content->compile = true;
         $content->createPage();   */

        $compileText=new compile_text();
        //$compileText->phpScriptPath=$this->phpScriptPath;
        $compileText->codeFilename=$data['code_filename'];
        //$compileText->systemPath=$this->systemPath;

        $compileText->pageUrl=$data['_url'];
        $text=$compileText->compileText($content);

        // Body Text speichern
        //$fileName=config::$distributionPath . "/code/content/page_text_" . $codeFilename . ".php";
        file::createTextFile(config::$basePath . $data['code_filename'], $text, false);


        // Header speichern
        /* $fileName=config::$distributionPath . "/code/content/page_text_" . $codeFilename . "_header.php";
         //$headerContent = $data['header'].$replaceCom->header;
         $headerContent=$this->header . $compileText->header;
         file::createTextFile($fileName, $headerContent, false);   */


        /*  $compileContentFile = new compile_content_file();
                 $compileContentFile->baseDir=$this->baseDir;
                 $compileContentFile->contentPath = $this->contentPath;
                 //$compileContentFile->
                 $compileContentFile->compileContentFile($folderItem['dir']); */

        //$url=config::$baseUrl . $data['_url'];
        $url=$data['_url'];
        
        http::redirect($url);
        ?></body>
</html>